package lambdaDemo;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

public class Test2 {
    public static void main(String[] args) {
        HashMap<String,Integer>map=new HashMap<>();
        map.put("hello",12);
        map.put("thank you",3);
        map.put("xixi",4);
       /* map.forEach(new BiConsumer<String, Integer>() {
            @Override
            public void accept(String s, Integer integer) {
                System.out.println("key :"+s+" value :"+integer);
            }
        });*/
        map.forEach((s,integer)-> System.out.println("key :"+s+" value :"+integer));
    }
    public static void main1(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("hello");
        list.add("thank you!");
        list.add("india,Mi fan!");
        /*list.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });*/

       /* list.sort(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.compareTo(o2);
            }
        });*/
        list.sort(((o1, o2) -> o1.compareTo(o2)));
        list.forEach(s -> System.out.println(s));
    }
}
